<?php
/**
 * 添加会员模板
 * User: crstu
 * Date: 2016/5/31
 * Time: 22:18
 */


use common\widgets\ActiveForm;
use common\widgets\FormTable;

$this->title = '修改会员基本信息';

$form = ActiveForm::begin([
    'title' => $this->title,
]);

if(!empty($paterID)){
    $model->paterTradeID = $model->paterUser->tradeID;
    $model->paterRealName = $model->paterUser->realName;
}

echo FormTable::widget([
    'model' => $model,
    'form' => $form,
    'labelWidth' => 4,
    'rows' => [
        'realName' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 3,
        ],
        'phone' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 3,
        ],
        'paterTradeID' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 3,
            'options' => ['id' => 'paterID']
        ],
        'paterRealName' => [
            'type' => FormTable::INPUT_TEXT,
            'width' => 3,
            'options' => ['id' => 'paterRealName', 'disabled' => 'disabled']
        ],
    ]
]);

$form->end();

$this->beginBlock('footJs');
?>
    <script type="text/javascript">
        $('#paterID').blur(function () {
            var id = $(this).val();
            if(id != ''){
                $.getJSON('/ajax/get-user-info.html', {tradeID:id}, function (response) {
                    if(response.status){
                        var realName = response.data.realName;
                        if(realName != ''){
                            $('#paterRealName').val(realName);
                        }else{
                            $('#paterRealName').val('姓名为空');
                        }
                    }else{
                        $('#paterRealName').val(response.message);
                    }
                })
            }
        });
        $('#bankCard').blur(function () {

        });
    </script>
<?php
$this->endBlock();